<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body>
    <div class="layui-form timo-compile">
    <form th:action="@{/ws/wsUser/sendMessage}">
        <input type="hidden" name="ids" th:if="${ids}" th:value="${ids}">
        <div class="layui-form-item">
            <label class="layui-form-label">模板</label>
            <div class="layui-input-inline">
                <select id="select-luodiye"  class="select-luodiye" name="mubanId"
                        th:attr="data-url=@{/ws/muban/list}" ></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">api账号</label>
            <div class="layui-input-inline">
                <select id="select-api"  class="select-businessApi" name="apiId"
                        th:attr="data-url=@{/ws/businessApi/list}" ></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发送电话</label>
            <div class="layui-input-inline">
                <select id="select-sendPhone"  class="select-sendPhone" name="phoneId"
                        th:attr="data-url=@{/ws/sendPhone/list}" ></select>
            </div>
        </div>

        <div class="layui-form-item timo-finally">
            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
    <script th:replace="/common/template :: script"></script>
    <script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
    <script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.core.min.js}"></script>
    <script type="text/javascript">

        layui.use(['form'], function () {
            window.form = layui.form;
        });



        (function($){
            var self;
            var SelectLuodiye=function(param){
                self=this;
                this.defaults={
                    tree: $(".select-luodiye"),
                    rootTree: null,
                    onSelected: function () {
                    }
                }
                this.options=$.extend({},this.defaults,param);
            }

            SelectLuodiye.prototype={
                // 初始化
                init: function(){
                    var luodiye = $(".select-luodiye");

                    var url = luodiye.data('url') ;
                    $.get(url, function (result) {
                        var options = '';
                        var datas = result.data;
                        for(let luodiyeData of datas){
                            var values = luodiyeData.id;
                            var valueString = luodiyeData.name;
                            options += "<option value='"+ values +"' "  + ">"+ valueString +"</option>";
                        }
                        luodiye.html(options);
                        form.render('select');
                    });
                }

            }

            $.fn.selectLuodiye=function(param){
                var selectLuodiye=new SelectLuodiye(param);
                return selectLuodiye.init();
            }
        })(jQuery);


        $.fn.selectLuodiye();

        (function($){
            var self;
            var SelectBusinessApi=function(param){
                self=this;
                this.defaults={
                    tree: $(".select-businessApi"),
                    rootTree: null,
                    onSelected: function () {
                    }
                }
                this.options=$.extend({},this.defaults,param);
            }

            SelectBusinessApi.prototype={
                // 初始化
                init: function(){
                    var luodiye = $(".select-businessApi");

                    var url = luodiye.data('url') ;
                    $.get(url, function (result) {
                        var options = '';
                        var datas = result.data;
                        for(let luodiyeData of datas){
                            var values = luodiyeData.id;
                            var valueString = luodiyeData.name;
                            options += "<option value='"+ values +"' "  + ">"+ valueString +"</option>";
                        }
                        luodiye.html(options);
                        form.render('select');
                    });
                }

            }

            $.fn.selectBusinessApi=function(param){
                var selectBusinessApi=new SelectBusinessApi(param);
                return selectBusinessApi.init();
            }
        })(jQuery);

        $.fn.selectBusinessApi();

        (function($){
            var self;
            var SelectSendPhone=function(param){
                self=this;
                this.defaults={
                    tree: $(".select-sendPhone"),
                    rootTree: null,
                    onSelected: function () {
                    }
                }
                this.options=$.extend({},this.defaults,param);
            }

            SelectSendPhone.prototype={
                // 初始化
                init: function(){
                    var luodiye = $(".select-sendPhone");

                    var url = luodiye.data('url') ;
                    $.get(url, function (result) {
                        var options = '';
                        var datas = result.data;
                        for(let luodiyeData of datas){
                            var values = luodiyeData.id;
                            var valueString = luodiyeData.name;
                            var phone = luodiyeData.phone;
                            options += "<option value='"+ values +"' "  + ">"+ valueString + " : (" + phone +  ")" +"</option>";
                        }
                        luodiye.html(options);
                        form.render('select');
                    });
                }

            }

            $.fn.selectSendPhone=function(param){
                var selectSendPhone=new SelectSendPhone(param);
                return selectSendPhone.init();
            }
        })(jQuery);

        $.fn.selectSendPhone();
    </script>
</body>
</html>